<template>
  <div class="home">
    <!-- swipe -->
    <van-swipe
      class="my-swipe"
      :autoplay="3000"
      indicator-color="white"
    >
      <van-swipe-item
        v-for="item in lunbolist"
        :key="item.id"
      >
        <img
          v-lazy="item.img"
          alt=""
        />
      </van-swipe-item>
    </van-swipe>
    <!-- grid -->
    <van-grid
      class="my-grid"
      :column-num="3"
    >
      <van-grid-item
        v-for="grid in grids"
        :key="grid.id"
        :icon="grid.src"
        :text="grid.title"
        :to="grid.to"
      />
    </van-grid>
  </div>
</template>
<script>
// import { getLunbo, getGrids } from '@/api'
export default {
  data() {
    return {
      lunbolist: [],
      grids: []
    }
  },
  created() {
    this.getLunbo()
    this.getGrids()
  },
  methods: {
    async getLunbo() {
      const res = await this.$http.getLunbo()
      this.lunbolist = res.data.message
    },
    async getGrids() {
      const res = await this.$http.getGrids()
      this.grids = res.data.message
    }
  }
}
</script>
<style lang="scss">
.home {
  .my-swipe .van-swipe-item {
    color: #fff;
    font-size: 20px;
    line-height: 200px;
    height: 200px;
    text-align: center;
    img {
      width: 100%;
      height: 100%;
      display: block;
    }
  }
  .my-grid {
    .van-grid-item__icon {
      font-size: 60px;
    }
  }
}
</style>
